<include file="public:no_bs_header" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadstyle/css/webuploader.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadstyle/css/diyUpload.css">
<script type="text/javascript" src="__STATIC__/admin/uploadstyle/js/webuploader.html5only.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/uploadstyle/js/diyUpload.js"></script>
<!--添加文章-->
<form id="info_form" action="{:U('article/edit')}" method="post" enctype="multipart/form-data">
	<div class="pad_lr_10" style="margin-top: 10px;">
		<div class="col_tab" id="col_tab">
			<ul class="J_tabs tab_but cu_li">
				<li href="#con1" class="current">{:L('article_basic')}</li>
				<li href="#con2">{:L('article_seo')}</li>
			</ul>
			<div class="J_panes">
				<div id="con1" class="content_list pad_10">
					<table width="100%" cellspacing="0" class="table_form">
						<tr>
							<th width="120">{:L('article_cateid')} :</th>
							<td>
								<select class="J_cate_select mr10" data-pid="0" data-uri="{:U('superadmin/article_cate/ajax_getchilds')}" data-selected="{$article.cate_path}">

								</select>
								<input type="hidden" name="cate_id" id="cate_id" value="{$article.cate_id}" /></td>
						</tr>
						<tr>
							<th>{:L('article_title')} :</th>
							<td>
								<input type="text" name="title" id="title" value="{$article.title}" class="input-text" size="30">
							</td>
						</tr>
						<tr>
							<th>{:L('author')} :</th>
							<td><input type="text" name="source" id="source" value="{$article.source}" class="input-text" size="30" value=""></td>
						</tr>
						<tr>
							<th>{:L('article_img')} :</th>
							<td>
								<div id="box">
									<div id="container" >
										<if condition="$article.thumb neq ''">
											<div style="width: 180px;" class="parentFileBox">
												<ul class="fileBoxUl">
													<li id="fileBox_" class="diyUploadHover">
														<div class="viewThumb">
															<img src="__ROOT__/upload/{$article.thumb}"></div>
														<div class="diyCancel"></div>
														<div class="diySuccess"></div>
														<div class="diyFileName">{$article.thumb}</div>
													</li>
												</ul>
											</div>
										</if>
									</div>
									<div id="test" ></div>
								</div>
								<input type="hidden" name="img" id="img" class="input-text" value="{$article.thumb}" /></td>
						</tr>
						<tr>
							<th>{:L('publish')} :</th>
							<td>
								<label><input type="radio" name="status" class="radio_style" value="1" <if condition="$article.status eq 1"> checked="checked" </if>> {:L('yes')} </label>&nbsp;&nbsp;
								<label><input type="radio" name="status" class="radio_style" value="0" <if condition="$article.status eq 0"> checked="checked" </if>> {:L('no')}</label>
							</td>
						</tr>
						<tr>
							<th>{:L('article_desc')} :</th>
							<td><textarea name="intro" id="abst" style="width:67%;height:50px;resize:none;">{$article.intro}</textarea></td>
						</tr>
						<tr>
							<th>详细内容 :</th>
							<td><textarea name="content" id="content" style="width:68%;height:400px;visibility:hidden;resize:none;">{$article.content}</textarea></td>
						</tr>
					</table>
				</div>
				<div  id="con2" class="content_list pad_10 hidden">
					<table width="100%" cellspacing="0" class="table_form">
						<tr>
							<th width="120">{:L('seo_title')} :</th>
							<td><input type="text" name="seo_title" value="{$article.seo_title}" id="seo_title" class="input-text" size="60"></td>
						</tr>
						<tr>
							<th>{:L('seo_keys')} :</th>
							<td><input type="text" name="seo_keywords" value="{$article.seo_keywords}" id="seo_keys" class="input-text" size="60"></td>
						</tr>
						<tr>
							<th>{:L('seo_desc')} :</th>
							<td><textarea name="seo_description" id="seo_desc" cols="80" rows="8">{$article.seo_description}</textarea></td>
						</tr>
					</table>
				</div>
			</div>
			<input type="hidden" id="json_cate_list" value='{$cate_list}'>
			<input type="hidden" name="id" value='{$article.id}'>
			<div class="mt10"><input type="button" value="{:L('submit')}" id="dosubmit" name="dosubmit" class="obtn obtn_submit" style="margin:0 0 10px 100px;"><br /><br /><br /></div>
		</div>
	</div>
</form>
<include file="public:footer" />
<script charset="utf-8" src="__STATIC__/editor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="__STATIC__/editor/lang/zh-CN.js"></script>

<script>
	$(function() {
		//初始化编辑器
		KindEditor.ready(function(K) {
			window.editor = K.create('#content',{
				width: '730px',
				height: '360px',
				afterBlur: function(){this.sync();}
			});
		});

		var cate_path = "{$article.cate_path}"
		var cate_source = $('#json_cate_list').val();
		cate_select_default(cate_source, cate_path)
		$('#dosubmit').click(function(){
		var cate_id = $('#cate_id').val();
		var title   = $('#title').val();
		var content = editor.html();
		if(!$.trim(cate_id))
		{
			layer.msg('请选择分类');
			return false;
		}
		if(!$.trim(title))
		{
			layer.msg('请输入文章标题');
			return false;
		}
		if(!$.trim(content))
		{
			layer.msg('请输入文章内容');
			return false;
		}
			$('#info_form').submit();
		});


		$('#test').diyUpload({
			fileNumLimit:1,
			container: 'container', //图片预览容器
			url:"{:U('upload/index', array('cate' => 'article'))}",
			success:function( data ) {
				//console.info(data.data.file.name);
				var img_path = '/article/'+ data.data.file.savepath + data.data.file.savename
				$('#img').val(img_path)
			},
			error:function( err ) {
				//console.info( err );
			}

		});
		$('.diyCancel').click(function(){
			$(this).parents('li').remove();
			$('#img').val('')
		})
	});

</script>
</body>
</html>